﻿using Perspective.Core.Wpf;
using System;
using System.Windows;

namespace Perspective.Wpf3D.Primitives
{
    /// <summary>
    /// 包含凹多边形特征的三维模型基类
    /// Basic abstract class for Perspective.Wpf3D elements with 
    /// an inner GeometryModel3D with concave polygonal dimensions.  
    /// </summary>
    public class ConcaveElement3D : GeometryElement3D
    {
        #region Constructors
        
         /// <summary>
        /// Static constructor.
        /// </summary>
        static ConcaveElement3D()
        {
            // No default back material for 3D closed shapes.
            BackMaterialProperty.OverrideMetadata(
                typeof(ConcaveElement3D),
                new PropertyMetadata(
                    null,
                    VisualPropertyChanged));
        }

        #endregion

        #region Properties

        #region BranchCount 角个数

        /// <summary>
        /// 角个数
        /// Gets or sets the branch count of the concave polygonal.
        /// </summary>
        public int BranchCount
        {
            get { return (int)GetValue(BranchCountProperty); }
            set { SetValue(BranchCountProperty, value); }
        }

        /// <summary>
        /// Identifies the BranchCount dependency property.
        /// </summary>
        public static readonly DependencyProperty BranchCountProperty =
            DependencyProperty.Register(
                "BranchCount",
                typeof(int),
                typeof(ConcaveElement3D),
                new FrameworkPropertyMetadata(
                    3,
                    FrameworkPropertyMetadataOptions.AffectsRender),
                    DPHelper.IsIntValueGreaterThan2);
        #endregion

        #region ConcaveRadius 凹圆半径
        /// <summary>
        /// 凹圆半径
        /// Gets or sets the concave polygon concave circle radius.
        /// Default value is 1.0.
        /// </summary>
        public double ConcaveRadius
        {
            get { return (double)GetValue(ConcaveRadiusProperty); }
            set { SetValue(ConcaveRadiusProperty, value); }
        }

        /// <summary>
        /// Identifies the concave circle radius dependency property.
        /// </summary>
        public static readonly DependencyProperty ConcaveRadiusProperty =
            DependencyProperty.Register(
                "ConcaveRadius",
                typeof(double),
                typeof(ConcaveElement3D),
                new UIPropertyMetadata(
                    0.2,
                    VisualPropertyChanged),
                    PositiveDoubleValidateValue);
        #endregion

        #region InitialAngle 初始角度

        /// <summary>
        /// 初始角度
        /// Gets or sets the initial angle (first point), in degrees.
        /// </summary>
        public double InitialAngle
        {
            get
            {
                return (double)base.GetValue(InitialAngleProperty);
            }
            set
            {
                base.SetValue(InitialAngleProperty, value);
            }
        }

        /// <summary>
        /// Identifies the InitialAngle dependency property.
        /// </summary>
        private static readonly DependencyProperty InitialAngleProperty =
            DependencyProperty.Register(
                "InitialAngle",
                typeof(double),
                typeof(ConcaveElement3D),
                new FrameworkPropertyMetadata(
                    0.0,
                    FrameworkPropertyMetadataOptions.AffectsRender));
        #endregion

        #endregion
    }
}
